import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';

// import App from './App';
import * as serviceWorker from './serviceWorker';
import { HashRouter as Router, Route, Switch, Redirect } from 'react-router-dom'
import { routes } from '@/router'

// import 'antd/dist/antd.css';//这种是全局引入,不推荐
import { Provider } from 'react-redux'
import store from '@/store'
// console.log(store.getState())//验证store

ReactDOM.render(
  <Provider store={store}>
    <Router>
      {/* 登录&注册&App */}
      <Switch>
        {
          routes.map(item => {
            const { path, component: Com } = item
            return <Route key={path} path={path}>
              <Com />
            </Route>
          })
        }
        <Redirect from="/" to="/blog" exact />
        <Redirect to="/notfound" />
      </Switch>
    </Router>
  </Provider>, document.getElementById('root'));

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
